Matrix-Vector Product
Introduction
The matrix–vector product is one of the most important ideas in linear algebra.
It acts as a bridge between simple vector operations and the powerful concept of linear transformations.
If you already know how to add vectors and scale them, you’re ready for this next step.
What Is a Matrix?
A matrix is a rectangular grid of numbers. For our purposes, think of it as a compact way to store several vectors at once.
- A $2 \times 2$ matrix looks like $$A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}$$
- You can think of this as two column vectors: $$A = \begin{bmatrix} a \\ c \end{bmatrix} \quad \begin{bmatrix} b \\ d \end{bmatrix}$$
Matrices allow us to apply the same operation to many vectors efficiently.
Defining the Matrix–Vector Product
Suppose we have a matrix $$A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}$$ and a vector $$x = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix}.$$ The matrix–vector product $Ax$ is defined as:
- Multiply each column of $A$ by the corresponding entry of $x$
- Then add the results
In symbols: $$Ax = x_1 \begin{bmatrix} a \\ c \end{bmatrix} + x_2 \begin{bmatrix} b \\ d \end{bmatrix}.$$ This is just a linear combination of the columns of $A$.
Why This Matters
The matrix–vector product is not just a computation trick. It encodes a rule for transforming vectors.
- Stretching
- Rotating
- Reflecting
- Shearing
- Projecting
All of these geometric actions can be expressed using matrices.
Key idea:
- A matrix is a machine that takes a vector as input and outputs a new vector.
This is the essence of a linear transformation.
Geometric Interpretation
When you multiply a matrix by a vector:
- Each column of the matrix shows where the basis vectors go.
- The input vector tells you how much of each column to combine.
Example:
If $$A = \begin{bmatrix} 2 & 0 \\ 0 & 3 \end{bmatrix},$$ then:
- The $x$-direction is stretched by a factor of $2$
- The $y$-direction is stretched by a factor of $3$
So $A$ scales space differently along each axis.
Computing Matrix–Vector Products
Here’s the standard computational rule for a $2 \times 2$ matrix: $$\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} = \begin{bmatrix} ax_1 + bx_2 \\ cx_1 + dx_2 \end{bmatrix}.$$ For a $3 \times 3$ matrix, the idea is the same—each row forms a dot product with the vector.
Examples
Example 1
Compute $$\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \begin{bmatrix} 5 \\ 1 \end{bmatrix}.$$
- First row: $1\cdot 5 + 2\cdot 1 = 7$
- Second row: $3\cdot 5 + 4\cdot 1 = 19$
Result: $$\begin{bmatrix} 7 \\ 19 \end{bmatrix}.$$
Example 2
Interpret $$\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}$$ geometrically.
This matrix rotates any vector by $90^\circ$ counterclockwise.
Calculator
Multiplying matrices and vectors
- A vector can be multiplied by a matrix in the same way as any other data type:
[1, 2; 3, 4] * [5, 1] multiply([2, 1; 0, 3], [4, -2])
Exercises
- Compute $$\begin{bmatrix} 2 & 1 \\ 0 & 3 \end{bmatrix} \begin{bmatrix} 4 \\ -2 \end{bmatrix}.$$
- Write the matrix–vector product $Ax$ as a linear combination of the columns of $A$ for $$A = \begin{bmatrix} 1 & -1 \\ 2 & 3 \end{bmatrix}, \quad x = \begin{bmatrix} 3 \\ 5 \end{bmatrix}.$$
- Compute $$\begin{bmatrix} 0 & 2 \\ -1 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 3 \end{bmatrix}.$$
- Describe in words what the matrix $$\begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix}$$ does to vectors.
- True or false: The matrix–vector product always produces a vector in the same dimension as the number of rows of the matrix.
- Compute $$\begin{bmatrix} 1 & 2 & 0 \\ -1 & 0 & 3 \end{bmatrix} \begin{bmatrix} 2 \\ 1 \\ -1 \end{bmatrix}.$$
- Express the matrix–vector product as a dot-product computation for $$A = \begin{bmatrix} 4 & 1 \\ 2 & -2 \end{bmatrix}, \quad x = \begin{bmatrix} 1 \\ 6 \end{bmatrix}.$$